﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._07_适配器模式
{

    /// <summary>
    /// 支付处理服务
    /// </summary>
    public class PaymentProcessor
    {
        private readonly IPaymentGateway _paymentGateway;

        public PaymentProcessor(IPaymentGateway paymentGateway )
        {
            _paymentGateway = paymentGateway;
        }

        /// <summary>
        /// 执行支付
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="amount"></param>
        /// <param name="currency"></param>
        public void ExecutePayment(string merchantId, decimal amount, string currency)
        {
            bool success = _paymentGateway.ProcessPayment(merchantId, amount, currency);
            if (success)
            {
                Console.WriteLine("支付成功！");
            }
            else
            {
                Console.WriteLine("支付失败，请重试");
            }
        }

        /// <summary>
        /// 检查支付状态
        /// </summary>
        /// <param name="transactionId"></param>
        public void CheckStatus(string transactionId)
        {
            string status = _paymentGateway.GetPaymentStatus(transactionId);
            Console.WriteLine($"支付状态: {status}");
        }

    }
}
